home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / windows5 / xwinc100.zip / CONTRIB-.00 / CONTRIB- / contrib / examples / PEX / sun_logo.c < prev    next >
C/C++ Source or Header  |  1991-02-16  |  8KB  |  285 lines

  1. /* $XConsortium: sun_logo.c,v 5.1 91/02/16 09:32:31 rws Exp $ */
  2.  
  3. /***********************************************************
  4. Copyright (c) 1991 by Sun Microsystems, Inc. and the X Consortium.
  5.  
  6.                         All Rights Reserved
  7.  
  8. Permission to use, copy, modify, and distribute this software and its 
  9. documentation for any purpose and without fee is hereby granted, 
  10. provided that the above copyright notice appear in all copies and that
  11. both that copyright notice and this permission notice appear in 
  12. supporting documentation, and that the names of Sun Microsystems,
  13. the X Consortium, and MIT not be used in advertising or publicity 
  14. pertaining to distribution of the software without specific, written 
  15. prior permission.  
  16.  
  17. SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
  18. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT 
  19. SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
  20. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23. SOFTWARE.
  24.  
  25. ******************************************************************/
  26.  
  27. /**********************************************************************/
  28. /* coordlogo.c                                                        */
  29. /**********************************************************************/
  30.  
  31. #include <phigs/phigs.h>
  32.  
  33. #define PI 3.14159265358
  34.  
  35. /**********************************************************************/
  36. /* Structure Definitions                                              */
  37. /**********************************************************************/
  38.  
  39. DefineAxes()
  40. {
  41.     Ppoint3 pts[2];
  42.     Pvec3 dir[2];
  43.     Ppoint_list3 colored_line;
  44.  
  45.     pts[0].x = pts[0].y = pts[0].z = 0.0;
  46.     pts[1].x = pts[1].y = pts[1].z = 0.0;
  47.  
  48.     /* x direction */
  49.     dir[0].delta_x = 1.0; 
  50.     dir[0].delta_y = 0.0; 
  51.     dir[0].delta_z = 0.0;   
  52.  
  53.     /* y direction */
  54.     dir[1].delta_x = 0.0; 
  55.     dir[1].delta_y = 1.0; 
  56.     dir[1].delta_z = 0.0;   
  57.  
  58.     colored_line.num_points = 2;       /* single line */
  59.     colored_line.points = pts;
  60.  
  61.     popen_struct(100);
  62.     pset_view_ind(1);
  63.     pset_text_colr_ind(4); /* blue */
  64.     pset_char_ht(1.0);
  65. /*    pset_text_font(PFONT_ROMAN_SIMPLEX); */
  66.     pset_line_colr_ind(4); /* blue */
  67.     pts[1].x = 15.0;
  68.     ppolyline3(&colored_line);
  69.     pts[1].x = 15.5;
  70.     pts[1].y = -0.5;
  71.     ptext3(&pts[1], dir, "X");
  72.     pts[1].x = 0.0;
  73.     pts[1].y = 15.0;
  74.         ppolyline3(&colored_line);
  75.     ptext3(&pts[1], dir, "Y");
  76.     pts[1].y = 0.0;
  77.     pts[1].z = 15.0;
  78.         ppolyline3(&colored_line);
  79.     dir[0].delta_x = 0.0; dir[0].delta_z = -1.0; 
  80.     dir[1].delta_x = 0.0; dir[1].delta_y = 1.0;
  81.     pts[1].z = 16.0;
  82.     pts[1].y = -0.5;
  83.     ptext3(&pts[1], dir, "Z");
  84.     pclose_struct();
  85. }
  86.  
  87. DefineObject()
  88. {
  89.     popen_struct(1);
  90.     pset_view_ind(1);
  91.         pexec_struct(5);
  92.     pclose_struct();
  93. }
  94.  
  95. DefineU()
  96. {
  97.     Ppoint3 pts[11];
  98.     Pvec3 p;
  99.     Pmatrix3 trans;
  100.     Pint err;
  101.     Ppoint_list3 colored_line;
  102.  
  103.     pts[0].x = -1.5; pts[0].y = -5.5; pts[0].z = 0.0;
  104.     pts[1].x = 1.5; pts[1].y = -5.5; pts[1].z = 0.0;
  105.     pts[2].x = 2.5; pts[2].y = -4.5; pts[2].z = 0.0;
  106.     pts[3].x = 2.5; pts[3].y = 5.5; pts[3].z = 0.0;
  107.     pts[4].x = 0.5; pts[4].y = 5.5; pts[4].z = 0.0;
  108.     pts[5].x = 0.5; pts[5].y = -3.5; pts[5].z = 0.0;
  109.     pts[6].x = -0.5; pts[6].y = -3.5; pts[6].z = 0.0;
  110.     pts[7].x = -0.5; pts[7].y = 5.5; pts[7].z = 0.0;
  111.     pts[8].x = -2.5; pts[8].y = 5.5; pts[8].z = 0.0;
  112.     pts[9].x = -2.5; pts[9].y = -4.5; pts[9].z = 0.0;
  113.     pts[10].x = -1.5; pts[10].y = -5.5; pts[10].z = 0.0;
  114.  
  115.     colored_line.num_points = 11;
  116.     colored_line.points = pts;
  117.  
  118.  
  119.     p.delta_x = 2.5;
  120.     p.delta_y = 5.5;
  121.     p.delta_z = 0.0;
  122.     ptranslate3(&p, &err, trans);
  123.     popen_struct(2);
  124.     pset_local_tran3(trans, PTYPE_REPLACE);
  125.         ppolyline3(&colored_line); 
  126.     pclose_struct();
  127. }
  128.  
  129. DefineUAStruct()
  130. {   
  131.     Pmatrix3    trans;
  132.     Pvec3    p;
  133.     Pint    err; 
  134.     popen_struct(3);
  135.     pset_line_colr_ind(1); /* white */
  136.         pexec_struct(2);
  137.         pset_line_colr_ind(7); /* magenta */
  138.     protate_z(PI, &err, trans);
  139.     pset_local_tran3(trans, PTYPE_REPLACE);
  140.     p.delta_x = -11.0;
  141.     p.delta_y = -11.0;
  142.     p.delta_z = 0.0;
  143.     ptranslate3(&p, &err, trans);
  144.     pset_local_tran3(trans, PTYPE_PRECONCAT);
  145.     pexec_struct(2);
  146.     pclose_struct();
  147. }
  148.  
  149. DefineLogoStruct()
  150. {
  151.     Pmatrix3    trans;
  152.     Pvec3    p;
  153.     Pint    err; 
  154.  
  155.     popen_struct(4);
  156.     pexec_struct(3);    /* lower left */
  157.  
  158.     protate_z(-PI/2, &err, trans);
  159.     pset_local_tran3(trans, PTYPE_PRECONCAT);
  160.     p.delta_x = -11.0;
  161.     p.delta_y = 12.0;
  162.     p.delta_z = 0.0;
  163.     ptranslate3(&p, &err, trans);
  164.     pset_local_tran3(trans, PTYPE_PRECONCAT);
  165.     pexec_struct(3);    /* lower right */
  166.  
  167.     protate_z(PI, &err, trans);
  168.     pset_local_tran3(trans, PTYPE_REPLACE);
  169.     p.delta_x = -23.0;
  170.     p.delta_y = -23.0;
  171.     p.delta_z = 0.0;
  172.     ptranslate3(&p, &err, trans);
  173.     pset_local_tran3(trans, PTYPE_PRECONCAT);
  174.     pexec_struct(3);    /* upper right */
  175.  
  176.     protate_z(PI/2, &err, trans);
  177.     pset_local_tran3(trans, PTYPE_REPLACE);
  178.     p.delta_x = 12.0;
  179.     p.delta_y = -11.0;
  180.     p.delta_z = 0.0;
  181.     ptranslate3(&p, &err, trans);
  182.     pset_local_tran3(trans, PTYPE_PRECONCAT);
  183.     pexec_struct(3);    /* upper left */
  184.     pclose_struct();
  185. }
  186.  
  187. DefineCubeStruct() 
  188. {   
  189.     Pmatrix3    rot, trans, composite;
  190.     Pvec3    p;
  191.     Pint    err;
  192.  
  193.     protate_y(PI/2, &err, rot);        /* just to be different */
  194.     p.delta_x = 23.5;
  195.     p.delta_y = 0.0;
  196.     p.delta_z = -0.5;
  197.     ptranslate3(&p, &err, trans);
  198.     pcompose_matrix3(trans, rot, &err, composite); /* just to be different */
  199.     
  200.     popen_struct(5);
  201.     pexec_struct(4);            /* left face */
  202.         pset_local_tran3(composite, PTYPE_REPLACE);
  203.         pexec_struct(4);            /* right face */
  204.     protate_x(-PI/2, &err, trans);
  205.     pset_local_tran3(trans, PTYPE_REPLACE);
  206.     p.delta_x = 0.0;
  207.     p.delta_y = .5;
  208.     p.delta_z = 23.5;
  209.     ptranslate3(&p, &err, trans);
  210.     pset_local_tran3(trans, PTYPE_PRECONCAT);
  211.     pexec_struct(4);
  212.     pclose_struct();
  213. }
  214.  
  215.  
  216. /**********************************************************************/
  217. /* View Information                                                   */
  218. /**********************************************************************/
  219.  
  220. DefineAViewRep()
  221. {
  222.     static Ppoint3  vrp;
  223.     static Pvec3 vpn;
  224.     static Pvec3 vup;
  225.     Pview_map3 viewmap;
  226.     Pint    err;
  227.     Pview_rep3    vrep;
  228.     
  229.     vrp.x = 23.0; vrp.y = 23.0; vrp.z = 0.0;
  230.     vpn.delta_x = 1.0; vpn.delta_y = 1.0; vpn.delta_z = 1.0;
  231.     vup.delta_x = 0.0; vup.delta_y = 1.0; vup.delta_z = 0.0;
  232.     peval_view_ori_matrix3(&vrp, &vpn, &vup, &err,
  233.     vrep.ori_matrix);
  234.  
  235.     viewmap.win.x_min = -30.0; viewmap.win.x_max = 30.0;
  236.     viewmap.win.y_min = -30.0; viewmap.win.y_max = 30.0;
  237.  
  238.     viewmap.view_plane = 0.0;
  239.     viewmap.back_plane = -40.0;
  240.     viewmap.front_plane = 30.0;
  241.  
  242.     viewmap.proj_ref_point.x = 0.0; 
  243.     viewmap.proj_ref_point.y = 0.0; 
  244.     viewmap.proj_ref_point.z = 45.0;
  245.     viewmap.proj_type = PTYPE_PARAL;
  246.  
  247.     viewmap.vp.x_min = 0.0; viewmap.vp.x_max = 1.0;
  248.     viewmap.vp.y_min = 0.0; viewmap.vp.y_max = 1.0;
  249.     viewmap.vp.z_min = 0.0; viewmap.vp.z_max = 1.0;
  250.     peval_view_map_matrix3(&viewmap, &err, vrep.map_matrix);
  251.  
  252.     vrep.clip_limit = viewmap.vp;
  253.     vrep.xy_clip = vrep.back_clip = vrep.front_clip = PIND_NO_CLIP;
  254.     pset_view_rep3(1, 1, &vrep);
  255. }
  256.  
  257. /**********************************************************************/
  258. /* Main                                                               */
  259. /**********************************************************************/
  260.  
  261. main()
  262. {
  263.     popen_phigs(PDEF_ERR_FILE, PDEF_MEM_SIZE);    /* open phigs */
  264.     popen_ws(1,NULL,phigs_ws_type_x_tool);     /* station 1  */
  265.     DefineAViewRep();
  266.  
  267.     DefineAxes();
  268.     DefineObject();
  269.     DefineU();
  270.     DefineUAStruct();
  271.     DefineLogoStruct();
  272.     DefineCubeStruct();
  273.  
  274.     ppost_struct(1,100,1.0);
  275.     ppost_struct(1,1,1.0);        /* post struct 1         */
  276.  
  277.     sleep(10);
  278.     pclose_ws(1);            /* close the workstation */
  279.     pclose_phigs();            /* close phigs           */
  280.  
  281. }
  282.  
  283.  
  284.  
  285.